package com.yanqu.road.server.cmd.activity.washe;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.WasheProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.washe.WasheModule;
import com.yanqu.road.server.manger.activity.washe.WasheMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_WASHE_GET_SHARE_REWARD, desc = "")
public class WasheGetShareRewardCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WasheProto.WasheShareRewardReqMsg reqMsg = WasheProto.WasheShareRewardReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (WasheMgr.getWasheConfig() == null) {
            ret = GameErrorCode.E_WASHE_NO_SYSTEM;
            return;
        }
        WasheModule washeModule = player.getModule(WasheModule.class);
        ret = washeModule.getShareRewardByCmd();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            WasheProto.WasheShareRewardRespMsg.Builder builder = WasheProto.WasheShareRewardRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_WASHE_GET_SHARE_REWARD, builder);
        }
    }
}
